package com.fafa.yygh.hosp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fafa.yygh.hosp.mapper.HospitalSetMapper;
import com.fafa.yygh.hosp.service.HospitalSetService;
import com.fafa.yygh.model.hosp.HospitalSet;
import com.fafa.yygh.vo.order.SignInfoVo;
import org.springframework.stereotype.Service;

/**
 * @author Sire
 * @version 1.0
 * @date 2022-02-01 15:53
 */
@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet> implements HospitalSetService {
    /**
     * 获取签名key
     *
     * @param hoscode
     * @return
     */
    @Override
    public String getSignKey(String hoscode) {
        // 注意这里是向mysql里查数据
        QueryWrapper<HospitalSet> wrapper = new QueryWrapper<>();
        wrapper.eq("hoscode", hoscode);
        HospitalSet hospitalSet = baseMapper.selectOne(wrapper);
        return hospitalSet.getSignKey();

    }

    /**
     * 获取医院签名信息
     *
     * @param hoscode
     * @return
     */
    @Override
    public SignInfoVo getSignInfoVo(String hoscode) {
        QueryWrapper<HospitalSet> wrapper = new QueryWrapper<>();
        wrapper.eq("hoscode", hoscode);
        HospitalSet hospitalSet = baseMapper.selectOne(wrapper);
        SignInfoVo signInfoVo = new SignInfoVo();
        signInfoVo.setApiUrl(hospitalSet.getApiUrl());
        // 记得加密
        signInfoVo.setSignKey(hospitalSet.getSignKey());
        return signInfoVo;
    }
}
